﻿using System.Threading.Tasks;
using SuperSocket.Command;
using SuperSocket.ProtoBase;
using SuperSocket.WebSocket.Server;

namespace SuperSocketV2Sample.WebSocketServer.Commands
{
    public abstract class BaseCommand : IAsyncCommand<WebSocketSession, StringPackageInfo>
    {
        public async ValueTask ExecuteAsync(WebSocketSession session, StringPackageInfo package)
        {
            await Task.Delay(0);

            var result = GetResult(package);

            //发送消息给客户端
            await session.SendAsync(result + "\r\n");
        }

        protected abstract string GetResult(StringPackageInfo package);
    }
}
